package net.ncraft.mc.ezframework.core.gui.esignv2;

import de.rapha149.signgui.SignGUI;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.util.List;

public class ESign {
    @Getter
    @Setter
    private String line1;
    @Getter
    @Setter
    private String line2;
    @Getter
    @Setter
    private String line3;
    @Getter
    @Setter
    private String line4;
    @Getter
    @Setter
    private SignAction onClose;

    public ESign() {
    }

    public ESign(String line1, String line2, String line3, String line4) {
        this.line1 = line1;
        this.line2 = line2;
        this.line3 = line3;
        this.line4 = line4;
    }

    public void open(Player player) {
        SignGUI signGUI = SignGUI.builder()
                .setLines(line1, line2, line3, line4)
                .setType(Material.OAK_SIGN)
                .setColor(DyeColor.BLACK)
                .setHandler((player1, result) -> {
                    String[] lines = result.getLines();
                    if (onClose != null) {
                        onClose.run(player1, lines);
                    }
                    return List.of();
                }).build();
        signGUI.open(player);
    }


}
